package cn.edu.nju.freshdelivery.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.edu.nju.freshdelivery.dao.OrderDAO;
import cn.edu.nju.freshdelivery.model.Buyer;
import cn.edu.nju.freshdelivery.model.Order;
import cn.edu.nju.freshdelivery.model.Seller;
import cn.edu.nju.freshdelivery.service.OrderService;

@Component
public class OrderServiceImpl implements OrderService {
	private OrderDAO orderDAO;

	public OrderDAO getOrderDAO() {
		return orderDAO;
	}

	@Resource
	public void setOrderDAO(OrderDAO orderDAO) {
		this.orderDAO = orderDAO;
	}

	public void add(Order order) {
		orderDAO.save(order);
	}

	public List<Order> findByBuyer(Buyer buyer) {
		return orderDAO.findByBuyer(buyer);
	}

	public List<Order> findBySeller(Seller seller) {
		return orderDAO.findBySeller(seller);
	}

	public Order findById(int id) {
		/**
		 * TODO: orderDetail
		 */
		return orderDAO.findById(id);
	}

}
